<template>
  <div id="app">
    <router-view v-if="isRouterAlive"></router-view>
  </div>
</template>

<script>
  import axios from 'axios'
  export default {
    name: 'App',
    provide () {
        return {
          reload:this.reload
        }
    },
    data () {
      return{
        isRouterAlive:true
      }
    },
    methods:{
      reload () {
          this.isRouterAlive = false;            //先关闭，
          this.$nextTick(function () {
              this.isRouterAlive = true;         //再打开
          }) 
      },
      getToken () {
          axios.get('/login/xCsrfToken')
             .then(this.getTokenSucc)
      },
      getTokenSucc (res) {
        res = res.data
        if (res.status==200 && res.data) {
          localStorage.setItem("x_csrf_token",res.data)
         }
      },
      updateListener(){
	      require('electron').ipcRenderer.on('ev-message', (event, message) => {//监听ping事件
		      console.log(message)  // Prints "whoooooooh!"  
		      this.$message({
			      dangerouslyUseHTMLString: true,
			      message: '<p>' + message + '</p>',
			      center:true,
			      offset:300,
			      duration:2000,
			      type: 'success'
		      })
	      })
      },
      getUpdateSucc(res){
        console.log(res)
        if(res.data.data.download){
          localStorage.setItem("downloadUrl",res.data.data.download)
          this.$message({
            dangerouslyUseHTMLString: true,
            message: '<p>亲，有新版本啦，点击右上角下载~</p>',
            center:true,
            offset:300,
            duration:2000,
            type: 'success'
          })
        }
        //awindow.location.href(res.data.download)
        // const shell = require('electron').shell
        // shell.openExternal(res.data.data.download)
      }
    },
    mounted () {
      this.getToken();
      this.updateListener();
    }    
  }
</script>

<style>
@import "./assets/styles/mixins.css";
@import "http://at.alicdn.com/t/font_2063873_bndi3vhw1g.css";
/*@import "./assets/font/SourceHanSansCN-Medium/SourceHanSansCN-Medium.css";
*/@import "./assets/font/SourceHanSansCN-Regular/SourceHanSansCN-Regular.css";
@import "./assets/font/Gilroy-Regular/Gilroy-Regular.css";

/*@font-face {
  font-family: "SourceHanSansCN-Medium";
  src: url("/assets/font/SourceHanSansCN-Medium/SourceHanSansCN-Medium.woff2") format("woff2"),
       url("/assets/font/SourceHanSansCN-Medium/SourceHanSansCN-Medium.woff") format("woff"),
       url("/assets/font/SourceHanSansCN-Medium/SourceHanSansCN-Medium.ttf") format("truetype"),
       url("/assets/font/SourceHanSansCN-Medium/SourceHanSansCN-Medium.eot") format("embedded-opentype"),
       url("/assets/font/SourceHanSansCN-Medium/SourceHanSansCN-Medium.svg") format("svg");
}*/
@font-face {
  font-family: "SourceHanSansCN-Regular";
  src: url("./assets/font/SourceHanSansCN-Regular/SourceHanSansCN-Regular.woff2") format("woff2"),
       url("./assets/font/SourceHanSansCN-Regular/SourceHanSansCN-Regular.woff") format("woff"),
       url("./assets/font/SourceHanSansCN-Regular/SourceHanSansCN-Regular.ttf") format("truetype"),
       url("./assets/font/SourceHanSansCN-Regular/SourceHanSansCN-Regular.eot") format("embedded-opentype"),
       url("./assets/font/SourceHanSansCN-Regular/SourceHanSansCN-Regular.svg") format("svg");
}
@font-face {
  font-family: "Gilroy-Regular";
  src: url("./assets/font/Gilroy-Regular/Gilroy-Regular.woff2") format("woff2"),
       url("./assets/font/Gilroy-Regular/Gilroy-Regular.woff") format("woff"),
       url("./assets/font/Gilroy-Regular/Gilroy-Regular.ttf") format("truetype"),
       url("./assets/font/Gilroy-Regular/Gilroy-Regular.eot") format("embedded-opentype"),
       url("./assets/font/Gilroy-Regular/Gilroy-Regular.svg") format("svg");
}
body,button,input::-webkit-input-placeholder,textarea::-webkit-input-placeholder,.el-input__inner{
  font-family: "Source Han Sans CN"!important;
  font-weight: 100;
}

body{
  margin:0;
}
#app{
  width: 1024px;
  height: 726px;
  margin:0 auto;
}

  .el-header {
  padding:0 !important;
  height: 122px !important;
}
.el-footer{
  height: 38px !important;
}

  .el-main {
    height: 566px !important;
    padding:20px 10px 0 10px;
  }
  
  .el-footer,.el-main{
    background-color: #F4F9FF;
  }
  .bluetit{
    font-size: 14px;
    border-left: 3px solid #2254E7;
    padding-left: 10px; 
  }
  .bluebtn{
    background: #1F71EE;
    color:#fff;
  }
 /* .serch .el-input__inner{
    height: 30px !important;
    line-height: 30px !important;
  }*/
  .el-input__inner,.el-textarea__inner{
    border-color: #bfbfbf;
  }
   input::-webkit-input-placeholder,textarea::-webkit-input-placeholder{
            color:#999 !important;
        }
        input::-moz-placeholder,textarea::-moz-placeholder{   /* Mozilla Firefox 19+ */
            color:#999 !important;
        }
        input:-moz-placeholder,textarea:-moz-placeholder{    /* Mozilla Firefox 4 to 18 */
            color:#999 !important;
        }
        input:-ms-input-placeholder,textarea:-ms-input-placeholder{  /* Internet Explorer 10-11 */ 
            color:#999 !important;
        }
  
    .recobox .el-textarea__inner{
    padding-top: 10px;
  }
  .el-range__icon,.el-range-separator{
    line-height: 22px!important;
  }
  .el-radio__input.is-checked .el-radio__inner {
    border-color: #2254E7; 
    background: #fff;
  }
  .el-radio__inner::after{
    background: #2254E7;
  } 
  .el-radio__input.is-checked+.el-radio__label/*,.el-checkbox__input.is-checked+.el-checkbox__label,.el-checkbox__input.is-checked .el-checkbox__inner*/{
    color: #2254E7; 
  }
 /* .el-checkbox__input.is-checked .el-checkbox__inner{
    border-color:#2254E7;
  }*/
  /*.el-checkbox__inner::after{
    border:1px solid #000 !important;
  }*/
  .el-dialog__header{
    text-align: center;
    background: #2254E7;
    padding:20px;
  }
  .el-dialog__title{
    color: #fff;
    font-size: 25px;
  }
  .el-dialog__headerbtn .el-dialog__close{
    color: #fff;
  }
  .el-carousel__container{
    height: 313px;
  }
  .el-dialog--center .el-dialog__body{
    padding:25px 75px;
  }
 .dialogbox .el-dialog {
    width: 405px;
  }
.el-tabs__content{
  height: 476px;
}
.advinput .el-textarea__inner{
        height: 100px;
    }

/*.el-checkbox__input.is-checked .el-checkbox__inner, .el-checkbox__input.is-indeterminate .el-checkbox__inner{
background-color:#666;
border-color: #666;
}
.el-checkbox__input.is-checked + .el-checkbox__label {
color: #666;
}
.el-checkbox.is-bordered.is-checked{
border-color: #666;
}
.el-checkbox__input.is-focus .el-checkbox__inner{
border-color: #666;
}*/
 .el-table td, .el-table th{
  padding:0;
 }

  .el-carousel__button{
    width: 6px;
    height: 6px;
    border-radius: 3px;
  }
  .el-carousel__indicator.el-carousel__indicator--horizontal.is-active .el-carousel__button{
    width: 18px;
    background: #256ff9;
  }
  .dialog-title{
    padding:0 50px; 
    margin:0 auto;
  }
   .jiuc{
     visibility:hidden;
  }

</style>
